import request from '@/utils/request'

/**
 * 获取学生列表
 * @param {Object} data: { page: 页码, pagesize: 每页条数, faculty: 学部, grade: 年级, s_class: 班级 }
 * @return Promise
 */
export const getStudentListAPI = (params) => {
  return request({
    url: '/student/',
    params
  })
}

/**
 * 查询学生
 * @param {Object} data: { s_number: 学号 }
 * @return Promise
 */
export const queryStudentAPI = (params) => {
  return request({
    url: '/student/query',
    params
  })
}

/**
 * 添加学生
 * @param {Object} data: { s_number: 学号, name: 姓名, faculty: 学部, grade: 年级, s_class: 班级, password: 密码, }
 * @return Promise
 */
export const addStudentAPI = (data) => {
  return request({
    url: '/student/',
    method: 'POST',
    data
  })
}

/**
 * 获取学生信息
 * @param id
 * @return Promise
 */
export const getStudentInfoAPI = (id) => {
  return request({
    url: `/student/${id}`
  })
}

/**
 * 修改学生信息
 * @param {Object} data: { id, s_number: 学号, name: 姓名, faculty: 学部, grade: 年级, s_class: 班级, phone: 手机号}
 * @return Promise
 */
export const updateStudentAPI = (data) => {
  return request({
    url: '/student/',
    method: 'PATCH',
    data
  })
}

/**
 * 删除学生
 * @param id
 * @return Promise
 */
export const deleteStudentAPI = (id) => {
  return request({
    url: `/student/${id}`,
    method: 'DELETE'
  })
}
